﻿using Autofac;
using Autofac.Integration.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;

namespace YouYi.YingShengBack.Web.Container
{
    public class AutofacConfing
    {
        public static void RegisterConfing()
        {
            // 创建一个容器
            var builder = new ContainerBuilder();
            // RegisterType方式：

            //builder.RegisterType<BrandRepository>().As<IBrandRepository>().InstancePerDependency();
            //builder.RegisterType<BrandService>().As<IBrandService>().InstancePerDependency();

           

            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces();
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
    }
}